<!DOCTYPE html>
<%@page import="domain.cull.Cull, domain.cull.SeasonalityCull"%>
<%@page import="svc.CullSvc, constants.Constants, utils.Utility"%>
<%
	String userName = "";
	if (request.getSession().getAttribute("name") != null) {
		userName = request.getSession().getAttribute("name").toString();
	}
	if (!userName.equals("")) {
		String fileNo = (String) session.getAttribute("fileNo");
		double unit = (Double)session.getAttribute("unit");
		
		Cull cull = (Cull) request.getAttribute("cull");
		SeasonalityCull seasonality = cull.getSeasonalityCull();
		double[] cullLact = cull.getCullRiskLact();
		double[] cullMim = cull.getCullRiskMim();
%>
<html lang="en">
<head>
<title>Set Values</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0; maximum-scale=1.0; user-scalable=0;">
<meta name="description" content="">
<meta name="author" content="">

<!-- Le styles -->
<link href="../css/bootstrap.css" rel="stylesheet">
<!--   <link href="../css/bootstrap-responsive.css" rel="stylesheet">-->
<link href="../css/docs.css" rel="stylesheet">
<link href="../css/google-code-prettify/prettify.css" rel="stylesheet">
<!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
<!--[if lt IE 9]>
      <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->




<style type="text/css">
body {
	padding-top: 60px;
	padding-bottom: 40px;
}
</style>




</head>

<body onLoad="displayCullResults()">

	<div class="navbar navbar-inverse navbar-fixed-top">
		<div class="navbar-inner">
			<div class="container">
				<a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
					<span class="icon-bar"></span>
					<span class="icon-bar"></span>
					<span class="icon-bar"></span>
				</a>
				<a class="brand" href="#">DairyVIP Project</a>
				<div class="nav-collapse collapse">
					<p class="navbar-text pull-right">
						Logged in as <a href="#" class="navbar-link"><%=userName%></a>
					</p>
					<ul class="nav">
						<li><a href="../jsp/index.jsp">Home</a></li>
						<li><a href="../jsp/acknowledgements_contro.jsp">Acknowledgements/Contributors</a></li>
						<li><a href='../jsp/dataset.jsp'>My DairyVIP</a></li>
					</ul>
				</div><!--/.nav-collapse -->
			</div>
		</div>
	</div>







	<!-- Docs nav
    ================================================== -->


	<div class="container">
		<div class="pagination ">
			<ul>
				<li><a href="../jsp/inputMisc">Misc</a></li>
				<li><a href="../jsp/inputPrice">Price</a></li>
				<li><a href="../jsp/inputMilk">Milk</a></li>
				<li class="active"><a href="#">Cull</a></li>
				<li><a href="../jsp/inputRepro">Repro</a></li>
				<li><a href="../jsp/inputBW">Bodyweight</a></li>
			</ul>
		</div>
	</div>

	<div class="container">
		<legend>
			<small>INVOLUNTARY CULLING</small>
		</legend>

		<form id="saveCull" name="saveCull" method="post">
			<div class="container0">

				<p>
					<a href="#" id="example1" rel="popover" data-content="Inv. cull function">Inv. cull function</a>
				</p>
				<table
					style="background-color: #f5f5f5; border: solid 1px #ccc; font-size: 12px">
					<tr>
						<td colspan="2">
							<table>
								<tbody>
									<tr>
										<td>+/- (abs)</td>
										<td><input type="text" class="span1"
											style="width: 45px; font-size: 80%;" value=<%= seasonality.getAbsAdjustment() %> name="cullabs"
											id="cullabs" onChange="displayCullResults()"></td>
									</tr>

									<tr>
										<td>+/- (%)</td>
										<td><input class="span1"
											style="width: 45px; display: inline; font-size: 80%;"
											id="cullpct" size="4" type="text" value=<%= seasonality.getPctAdjustment() * 100 %> name="cullpct"
											onChange="displayCullResults()">%</td>
									</tr>
									<!--<tr><td align="left">Seasonality:</td><td align="left"><input type="text" class="span1" style="width: 45px" id="cseasonality" size="4"  value="100" name="cseasonality" onChange="displayCullResults()"/>%</td></tr>-->
								</tbody>
							</table>
						</td>
					</tr>
					<tr>
						<!-- <td style="background-color: #f5f5f5; border: solid 1px #ccc;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td> -->
						<td style="background-color: #f5f5f5; border: solid 1px #ccc;">
							<table id="cullinput">
							
								<% for(int mim=1; mim<=24; mim++) {%>
								<tr>	
									<td>
										<input name="cullmim<%= mim %>" id="cullmim<%= mim %>" value=<%= cullMim[mim] * 100 %>
										type="text" class="span1" onchange="displayCullResults()"
										style="width: 25px; font-size: 12px; height: 15px; display: inline; padding: 2px; margin: 0px">
										%
									</td>
								</tr>
								<% } %>
								
							</table>
						</td>
					</tr>
				</table>
				<p></p>
				<!--<input class="btn" type="button" onclick="displayCullResults(); " value="Go" /> <br> <p>Please click this "Go" button. The computing results will be shown in the right table.</p><br>-->
			</div>

			<div class="span9">

     		<input class="btn" type="button" onclick="save(this.form)" value="Save" />
     		<input class="btn" type="button" onclick="saveAnalyze(this.form)" value="Save and Analyze" /><p></p>


				<table cellspacing="0" cellpadding="1">
					<thead>
						<tr>
							<th>Month</th>
							<th>&nbsp;&nbsp;</th>
							<% for(int sea=1; sea<=12; sea++) {%>
								<th><%= Constants.MONTHS[sea] %></th>
							<% } %>
						</tr>
					</thead>
					<tbody>
						<tr>
							<td align="left"><strong>Seasonality</strong></td>
							<td align="left">&nbsp;&nbsp;</td>
							
							<% for(int sea=1; sea<=12; sea++) {%>
							<td><input class="span1"
								style="width: 25px; height: 15px; font-size: 80%; padding: 2px; margin: 0px; display: inline"
								id="cullsea<%= sea %>" size="4" type="text" value=<%= seasonality.getMonthlySeasonality()[sea] * 100 %> name="cullsea<%= sea %>"
								onChange="displayCullResults()">%</td>
							<% } %>
							
						</tr>
					</tbody>
				</table>
				<p>&nbsp;</p>
				<h5>Probability of involuntary culling (open cows)</h5>

				<table id="myTable1" style="background-color: #f5f5f5; border: solid 1px #ccc;  font-size: 12px">

				</table>
				<p></p>
				<table style="font-size: 11px; border: #CCC solid 1px"
					cellspacing="0" cellpadding="1">
					<thead>
						<tr>
							<th colspan="8" style="border: #CCC solid 1px">Relative Risk
								of Involuntary culling per lactation number (%)</th>
						</tr>
					</thead>
					<tr>
						<td>lactatation</td>
						<% for(int lact=1; lact<=12; lact++) {%>
							<td><%= lact %></td>
						<% } %>
					</tr>
					<tr>
						<td></td>
						
						<% for(int lact=1; lact<=12; lact++) {%>
						<td><input class="span1"
							style="width: 25px; height: 15px; font-size: 80%; padding: 2px; margin: 0px; display: inline"
							id="culllact<%= lact %>" size="4" type="text" value=<%= cullLact[lact] * 100 %> name="culllact<%= lact %>">%</td>
						<% } %>
						
					</tr>
				</table>
				<!-- computing results
        ================================================== -->


			</div>



			<!-- hidden input mseasonality and mseaavg -->

			<input id="cullseaavg" size="4" type="hidden" value="100" name="cullseaavg" />
			<input type="hidden" class="span1" id="cseasonality" name="cseasonality" size="4" value="100" />
		</form>
	</div>


	<script language="javascript">
		function save(form)/*function to check userid & password*/
		{
			form.action = '../jsp/saveCull';
			form.submit();
			return true;
		}
		function saveAnalyze(form)/*function to check userid & password*/
		{
			form.action = '../jsp/saveAnalyzeCull';
			form.submit();
			return true;
		}
	</script>


	<p>&nbsp;</p>
	<footer class="footer">
		<%@ include file="../inc/footer.html"%>
	</footer>

	<!-- Le javascript
    ================================================== -->
	<!-- Placed at the end of the document so the pages load faster -->

	<script type="text/javascript" src="../js/jquery.js"></script>
	<script src="../js/bootstrap.js"></script>
	<%@ include file="floridacurvedata.html"%>
	<script>  
$(function ()  
{ $("#example1").popover({trigger: 'click',placement:'left'});  
  $("#example2").popover({trigger: 'click',placement:'right'});  
  $("#example3").popover({trigger: 'hover'});  
  $("#example4").popover({trigger: 'hover',placement:'right'}); 
});   
</script>
	<script src="../js/computing.js"></script>
</body>
</html>
<%}else
out.print("Please <a href='../jsp/login.jsp'>log in</a> first!");
%>